﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Text;

namespace Home.Domain.Entities.Example
{
    public class ExampleDbContext : DbContext
    {
        private readonly static string CONNECTION_STRING = "name=Example";
        public ExampleDbContext()
            : base(CONNECTION_STRING)
        {
            base.Configuration.ValidateOnSaveEnabled = false;//获取或设置一个值，该值指示是否跟踪的实体应验证自动调用 System.Data.Entity.DbContext.SaveChanges() 时。默认值为 true。
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();//生成的表名不加s
            modelBuilder.Configurations.Add(new UserInfoMap());
            modelBuilder.Configurations.Add(new CareerMap());
            //#region 不映射
            //modelBuilder.Ignore<Secondary.TPCUserInfo>(); 
            //#endregion
        }
        /// <summary>
        /// 职业
        /// </summary>
        public DbSet<Career> Careers { get; set; }
        /// <summary>
        /// 用户
        /// </summary>
        public DbSet<UserInfo> UserInfos { get; set; }
    }
}
